/* 聊天面板样式 */
.chat-panel {
    position: fixed;
    bottom: 90px;
    right: 24px;
    width: 600px;
    height: 500px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    border-radius: 12px;
    overflow: hidden;
    z-index: 999;
  }
  
  /* 修复Card头部样式 */
  .chat-panel .ant-card-head {
    background: linear-gradient(135deg, #1890ff 0%, #096dd9 100%);
    border-bottom: none;
    padding: 12px 16px;
    border-radius: 12px 12px 0 0;
    min-height: 60px;
  }
  
  .chat-panel .ant-card-head-title {
    color: white;
    font-weight: 500;
    line-height: 1.5;
  }
  
  .chat-panel .ant-card-body {
    padding: 0;
    height: 440px; /* 调整以适应头部 */
  }
  
  .chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    color: white;
  }
  
  .chat-header .anticon {
    color: white;
  }
  
  .chat-header button {
    color: white !important;
    border-color: transparent !important;
  }
  
  .chat-header button:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
  }
  
  /* 主体布局 - 左右分栏 */
  .chat-body {
    display: flex;
    height: 100%;
  }
  
  /* 左侧线程列表 */
  .thread-sidebar {
    width: 200px;
    background-color: #fafafa;
    border-right: 1px solid #f0f0f0;
    display: flex;
    flex-direction: column;
  }
  
  .thread-sidebar-header {
    padding: 12px;
    border-bottom: 1px solid #f0f0f0;
    background-color: #f5f5f5;
  }
  
  .thread-sidebar-header h4 {
    margin: 0;
    font-size: 14px;
    color: #666;
    font-weight: 500;
  }
  
  .thread-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
  }
  
  /* 线程项布局优化 - 移除 Dropdown，使用直接按钮 */
  .thread-item {
    cursor: pointer;
    border-radius: 8px;
    margin-bottom: 6px;
    padding: 12px 8px !important;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  
  .thread-item:hover {
    background-color: #e6f7ff;
    border-color: #91d5ff;
  }
  
  .thread-item.active {
    background-color: #1890ff;
    color: white;
    border-color: #1890ff;
  }
  
  .thread-item.active .ant-typography {
    color: white !important;
  }
  
  .thread-item-content {
    flex: 1;
    min-width: 0;
  }
  
  .thread-item-title {
    margin-bottom: 4px;
  }
  
  .thread-item-date {
    font-size: 11px;
    opacity: 0.8;
  }
  
  .thread-item-actions {
    opacity: 0;
    transition: opacity 0.2s ease;
    position: relative;
    z-index: 10;
    margin-left: 8px;
  }
  
  .thread-item:hover .thread-item-actions {
    opacity: 1;
  }
  
  .thread-item.active .thread-item-actions {
    opacity: 1;
  }
  
  .thread-item.active .thread-item-actions button {
    color: white !important;
  }
  
  .thread-item-actions .delete-button {
    color: #ff4d4f !important;
  }
  
  .thread-item.active .thread-item-actions .delete-button {
    color: white !important;
  }
  
  .thread-item-actions .delete-button:hover {
    background-color: rgba(255, 77, 79, 0.1) !important;
    color: #ff4d4f !important;
  }
  
  .thread-item.active .thread-item-actions .delete-button:hover {
    background-color: rgba(255, 255, 255, 0.2) !important;
    color: white !important;
  }
  
  /* 右侧聊天区域 */
  .chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: white;
  }
  
  /* 聊天区域头部 */
  .chat-area-header {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
    background-color: #fafafa;
  }
  
  .chat-area-title {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin: 0;
  }
  
  /* 消息容器 */
  .messages-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  
  .loading-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
  }
  
  .messages-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
  }
  
  /* 消息样式 */
  .message {
    display: flex;
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease;
  }
  
  .message.user {
    flex-direction: row-reverse;
  }
  
  .message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    margin: 0 8px;
    flex-shrink: 0;
  }
  
  .message.user .message-avatar {
    background-color: #1890ff;
    color: white;
  }
  
  .message.assistant .message-avatar {
    background-color: #52c41a;
    color: white;
  }
  
  .message-content {
    max-width: 280px;
    flex: 1;
  }
  
  .message.user .message-content {
    text-align: right;
  }
  
  .message-text {
    background-color: #f5f5f5;
    padding: 10px 14px;
    border-radius: 12px;
    margin-bottom: 4px;
    word-wrap: break-word;
    line-height: 1.4;
  }
  
  .message.user .message-text {
    background-color: #1890ff;
    color: white;
  }
  
  .message.user .message-text .ant-typography {
    color: white !important;
  }
  
  .message-sources {
    margin-top: 8px;
    padding: 8px 10px;
    background-color: #f0f0f0;
    border-radius: 8px;
    font-size: 11px;
  }
  
  .message.user .message-sources {
    background-color: rgba(255, 255, 255, 0.2);
  }
  
  .message-time {
    margin-top: 4px;
    font-size: 11px;
    opacity: 0.7;
  }
  
  /* 流式消息动画 */
  .message.streaming .message-text {
    border-bottom: 2px solid #1890ff;
    animation: pulse 1.5s infinite;
  }
  
  .typing-indicator {
    display: flex;
    align-items: center;
    margin-top: 8px;
  }
  
  .typing-indicator span {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background-color: #1890ff;
    margin: 0 1px;
    animation: typing 1.4s infinite ease-in-out;
  }
  
  .typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
  }
  
  .typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
  }
  
  /* 输入区域 */
  .input-container {
    padding: 12px 16px;
    border-top: 1px solid #f0f0f0;
    background-color: white;
  }
  
  .input-container .ant-input {
    border-radius: 8px; 
  }
  
  .input-container .ant-btn {
    border-radius: 8px;
    height: auto;
  }
  
  /* 空状态 */
  .empty-chat {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    color: #999;
  }
  
  .empty-chat .anticon {
    font-size: 48px;
    margin-bottom: 16px;
    color: #d9d9d9;
  }
  
  /* 动画 */
  @keyframes fadeIn {
    from {
      opacity: 0;
      transform: translateY(10px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  
  @keyframes pulse {
    0%, 100% {
      border-bottom-color: #1890ff;
    }
    50% {
      border-bottom-color: transparent;
    }
  }
  
  @keyframes typing {
    0%, 80%, 100% {
      transform: scale(0);
      opacity: 0.5;
    }
    40% {
      transform: scale(1);
      opacity: 1;
    }
  }
  
  /* 响应式设计 */
  @media (max-width: 768px) {
    .chat-panel {
      width: calc(100vw - 32px);
      right: 16px;
      bottom: 80px;
      height: 70vh;
    }
    
    .thread-sidebar {
      width: 150px;
    }
    
    .message-content {
      max-width: calc(100vw - 200px);
    }
  }
  
  /* 滚动条样式 */
  .messages-list::-webkit-scrollbar,
  .thread-list::-webkit-scrollbar {
    width: 4px;
  }
  
  .messages-list::-webkit-scrollbar-track,
  .thread-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 2px;
  }
  
  .messages-list::-webkit-scrollbar-thumb,
  .thread-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 2px;
  }
  
  .messages-list::-webkit-scrollbar-thumb:hover,
  .thread-list::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
  }
  
  /* Markdown 内容样式 */
  .markdown-content {
    line-height: 1.6;
    color: #333;
    text-align: left;
  }
  
  .markdown-content p {
    margin: 0.5em 0;
    word-wrap: break-word;
  }
  
  .markdown-content h1,
  .markdown-content h2,
  .markdown-content h3,
  .markdown-content h4,
  .markdown-content h5,
  .markdown-content h6 {
    margin: 1em 0 0.5em 0;
    font-weight: 600;
    line-height: 1.3;
  }
  
  .markdown-content h1 { font-size: 1.5em; }
  .markdown-content h2 { font-size: 1.3em; }
  .markdown-content h3 { font-size: 1.2em; }
  .markdown-content h4 { font-size: 1.1em; }
  .markdown-content h5 { font-size: 1em; }
  .markdown-content h6 { font-size: 0.9em; }
  
  /* 代码块容器样式 */
.markdown-content .code-block-wrapper {
  margin: 12px 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #333;
  background-color: #1e1e1e;
}

/* 代码块头部 */
.markdown-content .code-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background-color: #2d2d2d;
  border-bottom: 1px solid #333;
}

.markdown-content .code-language {
  color: #ccc;
  font-size: 12px;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-weight: 500;
}

.markdown-content .copy-code-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ccc;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.markdown-content .copy-code-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

/* 代码块样式 */
.markdown-content .code-block-wrapper pre {
  background-color: #1e1e1e;
  margin: 0;
  padding: 16px;
  overflow-x: auto;
  border: none;
  border-radius: 0;
}

.markdown-content .code-block-wrapper pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.4;
  color: #f8f8f2;
  display: block;
  white-space: pre;
}

/* 兼容旧的代码块样式 */
.markdown-content pre:not(.code-block-wrapper pre) {
  background-color: #1e1e1e;
  border-radius: 8px;
  padding: 16px;
  margin: 12px 0;
  overflow-x: auto;
  border: 1px solid #333;
  position: relative;
}

.markdown-content pre:not(.code-block-wrapper pre) code {
  background: transparent;
  padding: 0;
  border-radius: 0;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.4;
  color: #f8f8f2;
  display: block;
  white-space: pre;
}
  
  /* 行内代码样式 */
.markdown-content code {
  background-color: #f6f8fa;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.9em;
  color: #d73a49;
  border: 1px solid #e1e4e8;
}

/* 确保代码块中的code不受行内代码样式影响 */
.markdown-content pre code {
  background: transparent !important;
  padding: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  color: #f8f8f2 !important;
}
  
  /* 列表样式 */
  .markdown-content ul,
  .markdown-content ol {
    margin: 0.5em 0;
    padding-left: 2em;
  }
  
  .markdown-content li {
    margin: 0.25em 0;
  }
  
  .markdown-content ul li {
    list-style-type: disc;
  }
  
  .markdown-content ol li {
    list-style-type: decimal;
  }
  
  /* 引用样式 */
  .markdown-content blockquote {
    margin: 1em 0;
    padding: 0.5em 1em;
    border-left: 4px solid #1890ff;
    background-color: #f6f8fa;
    color: #666;
    font-style: italic;
  }
  
  /* 表格样式 */
  .markdown-content table {
    border-collapse: collapse;
    margin: 1em 0;
    width: 100%;
    font-size: 0.9em;
  }
  
  .markdown-content th,
  .markdown-content td {
    border: 1px solid #ddd;
    padding: 8px 12px;
    text-align: left;
  }
  
  .markdown-content th {
    background-color: #f8f9fa;
    font-weight: 600;
  }
  
  .markdown-content tr:nth-child(even) {
    background-color: #f9f9f9;
  }
  
  /* 链接样式 */
  .markdown-content a {
    color: #1890ff;
    text-decoration: none;
  }
  
  .markdown-content a:hover {
    text-decoration: underline;
  }
  
  /* 分割线样式 */
  .markdown-content hr {
    border: none;
    border-top: 1px solid #e1e4e8;
    margin: 1.5em 0;
  }
  
  /* 强调文本样式 */
  .markdown-content strong {
    font-weight: 600;
  }
  
  .markdown-content em {
    font-style: italic;
  }
  
  /* 确保AI回答内容左对齐 */
.message.assistant .message-content {
  text-align: left;
  width: 100%;
}

.message.assistant .markdown-content {
  text-align: left;
  width: 100%;
}

.message.assistant .message-text {
  text-align: left;
  width: 100%;
}

/* 确保用户消息右对齐 */
.message.user .message-content {
  text-align: right;
}

.message.user .message-text {
  text-align: right;
}
  
  /* 代码高亮主题调整 */
  .markdown-content pre code.hljs {
    background: #1e1e1e;
    color: #f8f8f2;
  }
  
  /* 滚动条样式优化 */
.markdown-content pre::-webkit-scrollbar,
.markdown-content .code-block-wrapper pre::-webkit-scrollbar {
  height: 8px;
}

.markdown-content pre::-webkit-scrollbar-track,
.markdown-content .code-block-wrapper pre::-webkit-scrollbar-track {
  background: #2d2d2d;
  border-radius: 4px;
}

.markdown-content pre::-webkit-scrollbar-thumb,
.markdown-content .code-block-wrapper pre::-webkit-scrollbar-thumb {
  background: #555;
  border-radius: 4px;
}

.markdown-content pre::-webkit-scrollbar-thumb:hover,
.markdown-content .code-block-wrapper pre::-webkit-scrollbar-thumb:hover {
  background: #777;
}

/* 复制按钮动画效果 */
.markdown-content .copy-code-btn {
  transition: all 0.2s ease;
}

.markdown-content .copy-code-btn:active {
  transform: scale(0.95);
}